﻿using Hardware.Info;
using System.Security.Cryptography;
using System.Text;

namespace BarrageGameAssistant.Core.Utils
{
    public class HwInfoUtils
    {
        private IHardwareInfo hardwareInfo = new HardwareInfo();

        public HwInfoUtils()
        {
            hardwareInfo.RefreshDriveList();
            hardwareInfo.RefreshNetworkAdapterList();
        }

        public string GetHwSN()
        {
            StringBuilder stringBuilder = new();
            foreach (Drive drive in hardwareInfo.DriveList)
            {
                if (!drive.Caption.ToLower().Contains("usb"))
                {
                    stringBuilder.Append(drive.SerialNumber);
                }
            }

            //foreach (NetworkAdapter networkAdapter in hardwareInfo.NetworkAdapterList)
            //{
            //    if (!networkAdapter.Caption.Contains("Bluetooth") && !networkAdapter.Caption.ToLower().Contains("usb") && !networkAdapter.Caption.ToLower().Contains("tap") && !networkAdapter.Caption.ToLower().Contains("vpn"))
            //    {
            //        stringBuilder.Append(networkAdapter.MACAddress);
            //    }
            //}

            byte[] b = MD5.HashData(Encoding.UTF8.GetBytes(stringBuilder.ToString() + "123wdsfj_+123dsakfh283423edas@#"));
            return new Guid(b).ToString("D").ToUpper();
        }
    }
}
